<template>
  <div class="personal_purse">
    <!-- <my-header :showBack="true" title="奖金"></my-header> -->
		<div class="ass_top">
      <div class="head_top">
        <div>
          <i class="iconfont icon-fanhui menu"  @click="goBack"></i>
        </div>
        <div>{{$t('lang.Seedpoints')}}</div>
        <div class="rightmenu">
          <p @click="pushPath('/myRegLsit')">{{$t('lang.SubAccount')}}</p>
        </div>
      </div>
    <div class="all_ass">
			<div>
				<h3>{{parseFloat(AssetNum.registerPoint).toFixed(3)||"0.00"}}</h3>
      	<p>{{$t('lang.Seedpoints')}}</p>
			</div>
      <div>
				<h3>{{parseFloat(AssetNum.activationPoint).toFixed(3)||"0.00"}}</h3>
      	<p>{{$t('lang.ActivationPoint')}}</p>
			</div>
    </div>
    </div>
		<!-- 02 -->
		<div class="myass_info">
			<ul>
				<li>
					<p>{{$t('lang.UseStock')}}</p><p>{{parseFloat(AssetNum.useStock).toFixed(3)||"0.000"}}</p>
				</li>
				<li>
					<p>{{$t('lang.FixedStock')}}</p><p>{{parseFloat(AssetNum.fixedStock).toFixed(3)||"0.000"}}</p>
				</li>
				<li>
					<p>{{$t('lang.DeliveryStock')}}</p><p>{{parseFloat(AssetNum.deliveryStock).toFixed(3)||"0.000"}}</p>
				</li>
			</ul>
		</div>
		<div class="ce_filed" @click="showSelet">
            <div class="ce_flex">
              <label for="">{{$t('lang.chooseLv')}}</label> 
            </div>
						<div class="ce_flex">
							<p  :data-id="UpTypeId">{{UpTypeName}}</p>
							<i class="iconfont icon-arrow-right"></i>
						</div>
		</div>
		<div class="tips">
        <p>{{$t('lang.uwdaarpftcl')}}</p>
    </div>
		<van-actionsheet
        v-model="show"
        :actions="actions"
        :cancel-text="$t('lang.cancel')"
        @select="onSelect"
      />
		<!-- button -->
		<div class="footer_btn mywallflex">
      <van-button type="primary" size="large" @click="pushPath('/myChildEXchange')">{{$t('lang.FractionalTransformation')}}</van-button>
      <van-button type="primary" size="large" @click="confirm">{{$t('lang.GenerateSubaccounts')}}</van-button>
    </div>

  </div>
</template>

<script>
import header from "@/components/header";
import { Toast } from 'vant';
import ClipboardJS from 'Clipboard'


export default {
  components: {
		"my-header": header,
  }, 
  data(){
    return{
			userInfo:{},

      showLeftProp: false,
			AssetNum: {},
			UpTypeName:"",
      UpTypeId:"",
      

      show:false,
      actions: [ ]
    }
  },
  filters: {
    formatDate(time) {
      var date = new Date(time);
      return timeFormat.formatDate(date, "yyyy.MM.dd hh:mm");
    }
  },
  mounted(){
    this.selectAccount();
    this.getLevels();
  },
  methods:{
		showProp(){
      this.showLeftProp=true;
    },
    closeProp(){
      this.showLeftProp=false;
    },
    selectAccount(){
			// 个人钱包信息
      this.$ajax(this.$api.childAccount).then(
        res=>{
          if(res.code==0){
            this.AssetNum=res.msg;
          }
        }
      )
    },
    getLevels(){
      //获取系统等级
      this.$ajax(this.$api.getLevels).then(res => {
        if (res.code == 0 && res.msg) {
          this.LeavetypeInfo=res.msg;
          this.UpTypeName=res.msg[0].levelName;
          this.UpTypeId=res.msg[0].id;
          const Arrlist=[];
          for (let index = 0; index < this.LeavetypeInfo.length; index++) {
            const name = this.LeavetypeInfo[index].levelName;
            const id = this.LeavetypeInfo[index].id;
            var objInfo = {name:name,id:id};
            Arrlist.push(objInfo);
          }
          this.actions=Arrlist;
          console.log(this.actions);
          
        }
      });
    },
    onSelect(item) {
      // 点击选项时默认不会关闭菜单，可以手动关闭
      this.show = false;
      Toast(item.name);
      this.UpTypeName=item.name;
      this.UpTypeId=item.id;
    },
    showSelet(){
      this.show=true;
    },
    confirm() {
      if(this.UpTypeId==""){
        Toast({ message: this.$t('lang.psml'), position: "bottom" });
        return;
			}
      this.$ajax(this.$api.generateChild, {id:this.UpTypeId}).then(res => {
        if (res.code === 0) {
          Toast({ message: this.$t('lang.CZsuccessful'), position: "bottom" });
          this.payWord="";
          this.selectAccount();
        }else{
          Toast({ message: res.msg, position: "bottom" });
        }
      });
    }
  }
}
</script>

<style lang='less' scoped>
.ass_top{background: url(../../assets/img/assetIndex/grzx_dhzx.png)}
.all_ass{
	text-align: center;padding:5vh 0;display: flex;justify-content:space-between;
	div{flex: 1;}
  h3{color: #E1AF56;font-size: 24px;line-height: 30px;}
  p{color: #AA7A24;}
}
// head_top
.head_top{
	width: 100%;
  height: 44px;
	line-height: 44px;
  font-size: 16px;
  color: #ffffff;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  background: transparent;      
}
.head_top .menu{font-size: 20px;}
.head_top i{
  padding:10px;
  font-size: 14px;
}
.head_top div:nth-child(1) {
  width:20%;
  box-sizing: border-box;
}
.head_top div:nth-child(2) {
  width:60%;
  text-align:center;
}
.head_top div:nth-child(3) {
  width:20%;
  text-align:center;
  font-size:12px;
}
// 
.personal_purse{
		background: #ffffff;
}
.trad_list{
		box-sizing: border-box;padding:0px 12px;background:#ffffff;margin-top:0px;
		h3{color: #333333;line-height: 26px;}
		li{padding: 10px 0;border-bottom: 1px solid #eeeeee;}
		.nflex{display: flex;justify-content:space-between ;
			p{line-height: 20px;color: #999999;}
			span{color: #333333;}
			.npadd{padding: 15px 0;}
			.tiphui{color: #999999;}
			.tipred{color: #FF5458;}
			.tipgren{color: #00BA4F;}
		}
		.buybtn{color: #FF4954;border: 1px solid #FF4954;border-radius: 20px;padding: 0 6px ;}		
}
.jytime{
	h3{color: #333333;font-size: 14px;}
	p{color: #CCCCCC;}
}
.myass_info{
	ul{
		li{display: flex;justify-content:space-between;box-sizing: border-box;padding: 12px 12px;border-bottom: 1px solid #eeeeee;background: #ffffff;}
		p:nth-child(1){color: #333333;}
		p:nth-child(2){color: #333333;}
	}
}
.tips{color: #EB0700;padding: 12px;}
.ce_filed{display: flex;justify-content:space-between ;box-sizing: border-box;padding: 10px 14px;border-bottom: 1px solid #eeeeee;background: #ffffff;}
.ce_filed label{max-width: 110px!important;width: 110px;text-align: left;}
.ce_flex{display: flex;justify-content:space-between;align-items:center;}
.ce_flex p{flex: 2;text-align: right;}
.mywallflex{
  display: flex;
  .van-button{margin: 0 10px;}
}
</style>
